import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:geomancy/styles/index.dart';

class StrokeText extends StatelessWidget {
  final String txt;
  final double? fontSize;
  final double? letterSpacing;
  final String? fontFamily;
  final Color? color;
  final FontWeight? fontWeight;
  final double? strokeWidth;
  const StrokeText({super.key, required this.txt, this.fontSize, this.letterSpacing, this.fontFamily, this.color, this.fontWeight, this.strokeWidth});

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        // 描边层
        Text(
          txt,
          style: TextStyle(
            fontSize: fontSize ?? 30.sp,
            letterSpacing: letterSpacing,
            fontFamily: fontFamily,
            fontWeight: fontWeight,
            foreground: Paint()
              ..style = PaintingStyle.stroke
              ..strokeWidth = strokeWidth ?? 5.sp
              ..color = ColorStyle.textColor,
          ),
        ),
        // 填充层
        Text(
          txt,
          style: TextStyle(
            fontSize: fontSize ?? 30.sp,
            letterSpacing: letterSpacing,
            fontFamily: fontFamily,
            fontWeight: fontWeight,
            color: color ?? ColorStyle.pageDefaultColor,
          ),
        ),
      ],
    );
  }
}
